module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
          options: {
              banner: '/*<%= grunt.template.today("yyyy-mm-dd") %> */'
          },
          commonJs: {
            src: ['public/common/js/*.js'],
            dest: 'public/common/common.js'
          },
          commonLess: {
            src: ['public/common/less/*.less'],
            dest: 'public/common/common.less'
          },
          indexLess: {
            src: ['public/modules/index/less/*.less'],
            dest: 'public/modules/index/index.less'
          }
    },
    less: {
      production: {
        options: {
          compress: true
        },
        files: {
          "public/common/common.css": "public/common/common.less",
          'public/modules/index/index.css': "public/modules/index/index.less"
        }
      }
    },
    watch: {
      options: {
        livereload: true
      },
      grunt: {
        files: ['Gruntfile.js']
      },

      styles: {
        files: [
                'public/common/js/*.js',
                'public/common/less/*.less',
                'public/modules/index/less/*.less'
        ],
        tasks: [
                'concat:commonJs',
                'concat:commonLess',
                'concat:indexLess',
                'less'
        ],
        options: {
          nospawn: true
        }
      }
    }
  });
 
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-watch');
 
  grunt.registerTask('default', ['watch']);
};